package com.bwie.groupon.controller;

import java.util.Arrays;
import java.util.Map;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bwie.groupon.entity.SubscriptionDeductionEntity;
import com.bwie.groupon.service.SubscriptionDeductionService;
import com.bwie.common.utils.PageUtils;
import com.bwie.common.utils.R;



/**
 * 
 *
 * @author wangguohai
 * @email 270901876@qq.com
 * @date 2022-04-26 19:40:22
 */
@RestController
@RequestMapping("groupon/subscriptiondeduction")
public class SubscriptionDeductionController {
    @Autowired
    private SubscriptionDeductionService subscriptionDeductionService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = subscriptionDeductionService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{deductionId}")
    public R info(@PathVariable("deductionId") Integer deductionId){
		SubscriptionDeductionEntity subscriptionDeduction = subscriptionDeductionService.getById(deductionId);

        return R.ok().put("subscriptionDeduction", subscriptionDeduction);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody SubscriptionDeductionEntity subscriptionDeduction){
		subscriptionDeductionService.save(subscriptionDeduction);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody SubscriptionDeductionEntity subscriptionDeduction){
		subscriptionDeductionService.updateById(subscriptionDeduction);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] deductionIds){
		subscriptionDeductionService.removeByIds(Arrays.asList(deductionIds));

        return R.ok();
    }

}
